package com.mofeng.myshop.domain.dto;

import com.mofeng.myshop.domain.dto.base.BaseDto;
import com.mofeng.myshop.domain.po.Carmine;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;

/**
 * @author 作者
 * @since 2024-11-10
 */
@Schema(name = "Carmine Dto", description = "卡密")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class CarmineDto extends BaseDto {

    @Schema(description = "金额")
    private String money;

    @Schema(description = "卡密")
    private String uuid;

    @Schema(description = "使用用户")
    private Long userId;

    @Schema(description = "是否使用  0没使用 1使用")
    private Integer used;

    @Schema(description = "开卡数量")
    private Integer count;


    /**
     * 转换为 Carmine 实体
     */
    public Carmine toEntity() {
        Carmine carmine = new Carmine();
        super.toBaseEntity(carmine);
        if (this.money != null) {
            carmine.setMoney(this.money);
        }
        if (this.uuid != null) {
            carmine.setUuid(this.uuid);
        }
        if (this.userId != null) {
            carmine.setUserId(this.userId);
        }
        if (this.used != null) {
            carmine.setUsed(this.used);
        }
        return carmine;
    }

}